# This package defines the in-memory representation of ScaNN datasets and
# datapoints.

load("//scann/oss_wrappers:build_defs.bzl", "scann_py_proto_library")

package(
    default_visibility = ["//visibility:public"],
    licenses = ["notice"],
)

# Generated Files
# ==================================================================

proto_library(
    name = "features_proto",
    srcs = ["features.proto"],
    features = ["-proto_dynamic_mode_static_link"],
    tags = ["local"],
    deps = [
        "@com_google_protobuf//:timestamp_proto",
    ],
)

cc_proto_library(
    name = "features_cc_proto",
    tags = ["local"],
    deps = [":features_proto"],
)

scann_py_proto_library(
    name = "features_py_pb2",
    srcs = ["features.proto"],
    proto_deps = [":features_proto"],
    py_proto_deps = [],
    tags = ["local"],
)

# Libraries
# ==================================================================

cc_library(
    name = "gfv_conversion",
    hdrs = ["gfv_conversion.h"],
    tags = ["local"],
    deps = [
        ":features_cc_proto",
        ":gfv_properties",
        "//scann/utils:common",
        "//scann/utils:types",
    ],
)

cc_library(
    name = "datapoint",
    srcs = ["datapoint.cc"],
    hdrs = ["datapoint.h"],
    tags = ["local"],
    deps = [
        ":features_cc_proto",
        ":gfv_conversion",
        ":gfv_properties",
        "//scann/oss_wrappers:scann_status",
        "//scann/proto:hashed_cc_proto",
        "//scann/utils:infinite_one_array",
        "//scann/utils:types",
        "//scann/utils:zip_sort",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "dataset",
    srcs = [
        "dataset.cc",
        "dataset_mutator.cc",
    ],
    hdrs = ["dataset.h"],
    tags = ["local"],
    deps = [
        ":datapoint",
        ":docid_collection",
        ":docid_collection_interface",
        ":features_cc_proto",
        ":gfv_conversion",
        ":gfv_properties",
        ":sparse_low_level",
        "//scann/distance_measures:distance_measure_base",
        "//scann/distance_measures/one_to_one:l2_distance",
        "//scann/oss_wrappers:scann_aligned_malloc",
        "//scann/oss_wrappers:tf_dependency",
        "//scann/proto:hashed_cc_proto",
        "//scann/utils:common",
        "//scann/utils:datapoint_utils",
        "//scann/utils:iterators",
        "//scann/utils:memory_logging",
        "//scann/utils:types",
        "//scann/utils:util_functions",
        "//scann/utils:zip_sort",
        "@com_google_absl//absl/container:flat_hash_set",
        "@com_google_absl//absl/memory",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/time",
    ],
)

cc_library(
    name = "docid_collection_interface",
    hdrs = ["docid_collection_interface.h"],
    tags = ["local"],
    deps = [
        ":docid_lookup",
        "//scann/utils:common",
        "//scann/utils:types",
    ],
)

cc_library(
    name = "docid_collection",
    srcs = ["docid_collection.cc"],
    hdrs = ["docid_collection.h"],
    tags = ["local"],
    deps = [
        ":docid_collection_interface",
        "//scann/data_format/internal:short_string_optimized_string",
        "//scann/data_format/internal:string_view32",
        "//scann/oss_wrappers:scann_aligned_malloc",
        "//scann/oss_wrappers:scann_down_cast",
        "//scann/oss_wrappers:scann_serialize",
        "//scann/oss_wrappers:scann_status",
        "//scann/oss_wrappers:tf_dependency",
        "//scann/utils:common",
        "//scann/utils:memory_logging",
        "//scann/utils:types",
        "//scann/utils:util_functions",
        "@com_google_absl//absl/base",
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/flags:flag",
        "@com_google_absl//absl/log",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "docid_lookup",
    hdrs = ["docid_lookup.h"],
    tags = ["local"],
    deps = [
        "//scann/utils:common",
        "//scann/utils:types",
        "@com_google_absl//absl/functional:any_invocable",
    ],
)

cc_library(
    name = "gfv_properties",
    srcs = ["gfv_properties.cc"],
    hdrs = ["gfv_properties.h"],
    tags = ["local"],
    deps = [
        ":features_cc_proto",
        "//scann/oss_wrappers:scann_aligned_malloc",
        "//scann/oss_wrappers:scann_down_cast",
        "//scann/oss_wrappers:scann_status",
        "//scann/oss_wrappers:tf_dependency",
        "//scann/utils:types",
        "@com_google_absl//absl/base",
        "@com_google_absl//absl/flags:flag",
        "@com_google_absl//absl/log",
    ],
)

cc_library(
    name = "sparse_low_level",
    hdrs = ["sparse_low_level.h"],
    tags = ["local"],
    deps = [
        "//scann/utils:types",
    ],
)

# Unit Tests
# ==================================================================
